#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<sstream>

using namespace std;

int main()
{
    string a, b, c, d;
    getline(cin, a);
    cin >> b >> c;
    stringstream ssin(a);
    while (ssin >> d)
    {
        if (d == b)
            cout << c << ' ';
        else
            cout << d << ' ';
    }
    return 0;
}